#ifndef MULTIROWHEADERTABLE_H
#define MULTIROWHEADERTABLE_H

#include <QObject>
#include <QTableWidget>
#include <QStyledItemDelegate>
#include <QPainter>
#include "itemdelegate.h"

class MultiRowHeaderTable : public QTableWidget
{
    Q_OBJECT
public:
    explicit MultiRowHeaderTable(QWidget *parent = nullptr);
    QTableWidget * getHeaderTable();
    QTableWidget * getContentTable();
    void initWidget();
    void setHeaderRowCount(int num);
    void setColumnNum(int num);
    void setContentRowCount(int num);
    void setHeaderRowHeight(int height);//set height for each row of header table
    void setContentRowHeight(int height);//set height for each row of content table

signals:

public slots:

protected:
    // 重载虚函数 resize事件，同时更新m_frozenTableWgt的位置
    virtual void resizeEvent(QResizeEvent * event) Q_DECL_OVERRIDE;
    //重载虚函数 鼠标移动事件
    virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
    //TableWidget移动事件
    void scrollTo (const QModelIndex & index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE;

private:
    void initHeaderWidget();
    void initContentWidget();
    //更新被冻结的tableWidget位置
    void updateHeaderTableGeometry();

private:
    QTableWidget * headerTable;
    int headerRowCount ;   //row count of header table
    int headerColCount ;   //表头列数，需与内容列数一致
    int headerRowHeight;   //表头高度

    int contentRowCount;   //row count of content table
    int contentColCount;   //column count of content table
    int contentRowHeight;  //内容每行高度

};

#endif // MULTIROWHEADERTABLE_H
